<%@include file="/WEB-INF/views/includes/taglibs.jsp"%>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<h3>Edit Status Rule</h3>
<form:form method="post" action="editStatusRule" id="editARuleform">
		<form:input path="functionId" type="hidden"/>
		<form:input path="conditionEditIndex" type="hidden"/>
		<form:input path="operation2" type="hidden"/>
		<form:input path="ruleId" type="hidden"/>
		<div style="font-size:12px;margin-bottom:10px"><span class="label" style="width:100px">Status becomes</span><span><form:select path="editRuleStatus" autocomplete="off">
						 <form:options items="${functionStatusList}"  itemValue="id" itemLabel="name" />
					</form:select></span></div>
		<div style="font-size:12px;margin-bottom:10px"><span 
			class="label" style="width:100px">When</span><span><a 
			href="#" onclick="addCondition('editRuleRanges', 'conditionEditIndex', 'editFilterRuleDialog')">Add condition</a>&nbsp;&nbsp;
			(Tips: the connector between conditions is 'and')</span>
		</div>
		<div style="width:700px;margin-left:10px;">
			<table>
				<thead>
					<tr style="background:#969696 fixed;color:#FFFFFF">
					<th style="width:230px;text-align:left">&nbsp;Field Name</th>
					<th style="width:180px;text-align:left">&nbsp;Comparator</th>
					<th style="width:140px;text-align:left">&nbsp;Value</th>
					<th style="width:100px;text-align:left">&nbsp;</th>
					</tr>
				</thead>
				<tbody id="editRuleRanges">
					<c:forEach items="${command.statusConditionList}" var="oneStatusCondidtion" varStatus="currentStep">
				<tr style="width:100%;line-height:26px" id="conditionBlock${currentStep.count - 1}">
					<input type="hidden" name="statusConditionList[${currentStep.count - 1}].ruleId" value="${oneStatusCondidtion.ruleId}" id="statusConditionList[${currentStep.count - 1}].ruleId"/>
					<td style="width:250px;">
						<select style="width:250px" name="statusConditionList[${currentStep.count - 1}].fieldName" id="statusConditionList[${currentStep.count - 1}].fieldName">
							<c:forEach items="${functionSchemaList}" var="functionSchema">
								<c:if test="${oneStatusCondidtion.fieldName == functionSchema.fieldName}">
									<option value="${functionSchema.fieldName}" selected="selected">${functionSchema.fieldName}</option>
								</c:if>
								<c:if test="${oneStatusCondidtion.fieldName != functionSchema.fieldName}">
									<option value="${functionSchema.fieldName}">${functionSchema.fieldName}</option>
								</c:if>
							</c:forEach>
						</select>
					</td>
					<td style="width:180px;"> 
						<select style="width:180px" name="statusConditionList[${currentStep.count - 1}].comparator" id="statusConditionList[${currentStep.count - 1}].comparator">
							<c:forEach items="${comparatorList}" var="comparator">
								<c:if test="${oneStatusCondidtion.comparator == comparator}">
									<option value="${comparator}" selected="selected">${comparator}</option>
								</c:if>
								<c:if test="${oneStatusCondidtion.comparator != comparator}">
									<option value="${comparator}">${comparator}</option>
								</c:if>
							</c:forEach>
						</select>
					</td>
					<td style="width:140px;"><input style="width:120px" type="text" value="${oneStatusCondidtion.compareData}" name="statusConditionList[${currentStep.count - 1}].compareData" id="statusConditionList[${currentStep.count - 1}].compareData"></td>
					<td style="width:100px;">&nbsp;&nbsp;<a onclick="deleteCondition(${currentStep.count - 1}, 'editFilterRuleDialog')" href="#">delete</a></td>
					<input type="hidden" name="statusConditionList[${currentStep.count - 1}].enabled" value="true" id="statusConditionList[${currentStep.count - 1}].enabled">
				</tr>
				
			</c:forEach>
				</tbody>
			</table>
		</div>
	</form:form>
	<br/>